﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 原型模式
{
    /// <summary>
    /// 1 单例模式/原型模式
    /// 2 浅克隆VS深克隆
    /// 3 原型模式的应用
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("**********************************");
            //{
            //    for (int i = 0; i < 5; i++)
            //    {
            //        Student student = new Student();
            //        student.Id = 88888;
            //        student.Name = "大黄瓜";
            //        student.Study();
            //    }
            //}
            //{
            //    Console.WriteLine("**********************************");
            //    for (int i = 0; i < 5; i++)
            //    {
            //        StudentSingleton studentSingleton = StudentSingleton.CreateInstance();
            //        studentSingleton.Study();
            //    }
            //}

            //{
            //    Console.WriteLine("**********************************");
            //    for (int i = 0; i < 5; i++)
            //    {
            //        StudentSingleton studentSingleton1 = StudentSingleton.CreateInstance();
            //        StudentSingleton studentSingleton2 = StudentSingleton.CreateInstance();
            //        studentSingleton1.Id = 18888;
            //        studentSingleton1.Name = "帅逼大黄瓜";
            //        Console.WriteLine($"{studentSingleton1.Id} {studentSingleton1.Name}");
            //        Console.WriteLine($"{studentSingleton2.Id} {studentSingleton2.Name}");
            //    }
            //}

            //{
            //    Console.WriteLine("**********************************");
            //    for (int i = 0; i < 5; i++)
            //    {
            //        StudentPrototype studentPrototype = StudentPrototype.CreateInstance();
            //        studentPrototype.Study();
            //    }
            //}

            //{
            //    Console.WriteLine("**********************************");
            //    for (int i = 0; i < 5; i++)
            //    {
            //        StudentPrototype studentPrototype1 = StudentPrototype.CreateInstance();
            //        StudentPrototype studentPrototype2 = StudentPrototype.CreateInstance();
            //        studentPrototype1.Id = 18888;
            //        studentPrototype1.Name = "帅逼大黄瓜001";
            //        Console.WriteLine($"{studentPrototype1.Id} {studentPrototype1.Name}");
            //        Console.WriteLine($"{studentPrototype2.Id} {studentPrototype2.Name}");
            //    }
            //}


            {
                Console.WriteLine("**********************************");
                for (int i = 0; i < 5; i++)
                {
                    StudentPrototype studentPrototype1 = StudentPrototype.CreateInstance();
                    StudentPrototype studentPrototype2 = StudentPrototype.CreateInstance();
                    studentPrototype1.Class.Num = 2;
                    studentPrototype1.Class.Remark = "帅逼大黄瓜0022";
                    Console.WriteLine($"{studentPrototype1.Class.Num} {studentPrototype1.Class.Remark}");
                    Console.WriteLine($"{studentPrototype2.Class.Num} {studentPrototype2.Class.Remark}");
                }
            }


            Console.WriteLine("**********************************");
            {
                StudentPrototype student1 = StudentPrototype.CreateInstanceSerialize();
                StudentPrototype student2 = StudentPrototype.CreateInstanceSerialize();

                student1.Id = 888888;
                student1.Name = "帅逼大黄瓜212";
                Console.WriteLine("Id {0} Name {1}", student1.Id, student1.Name);
                Console.WriteLine("Id {0} Name {1}", student2.Id, student2.Name);

                student1.Class.Num = 2;
                student1.Class.Remark = "特训班";

                Console.WriteLine("Class.Num {0} Class.Remark {1}", student1.Class.Num, student1.Class.Remark);
                Console.WriteLine("Class.Num {0} Class.Remark {1}", student2.Class.Num, student2.Class.Remark);
            }
            Console.Read();
        }
    }
}
